﻿<%@ Page Title="" Language="C#" MasterPageFile="~/common/Admin.master" AutoEventWireup="true" CodeFile="TransactionStatistics.aspx.cs" Inherits="statistics_TransactionStatistics" %>

<asp:Content ID="Content1" ContentPlaceHolderID="html_css" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="html_js" Runat="Server">
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
    </style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="leftMenu" Runat="Server">
  <ul>
        <li><a href="<%= Page.ResolveUrl("~/statistics/Statistics.aspx")%>">Age Group Statistics</a></li>
        <li><a href="<%= Page.ResolveUrl("~/statistics/TransactionStatistics.aspx")%>">Transation Statistics</a></li>
       
    </ul>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="content" Runat="Server">
    <p>
        <br />
    </p>
    <p><h2>Yearly Transaction</h2></p>
    <p>
        <asp:HiddenField ID="selectedYear" runat="server" />
        <asp:Repeater ID="RepeaterTopTenYears" runat="server" 
            onitemcommand="RepeaterTopTenYears_ItemCommand">
            <ItemTemplate>
            <asp:LinkButton CommandName="changeYear" runat="server" CommandArgument='<%# Container.DataItem %>' Text='<%# Container.DataItem %>'></asp:LinkButton>
            <span style="padding:10px"/>
            </ItemTemplate>
        </asp:Repeater>
    </p>
    <p>
        <asp:Chart ID="ChartTransaction" runat="server" 
            DataSourceID="SqlDataSourceTransaction">
            <Series>
                <asp:Series ChartType="Line" Name="Series1" XValueMember="transactionDate" 
                    YValueMembers="transactionAmount">
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea Name="ChartArea1">
                </asp:ChartArea>
            </ChartAreas>
        </asp:Chart>
        <asp:SqlDataSource ID="SqlDataSourceTransaction" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT CONVERT(Nvarchar(7),  transactionDate,111) AS transactionDate, SUM(abs(transactionAmount) )transactionAmount  FROM SUMMARY
where  CONVERT(Nvarchar(4),  transactionDate,112)=@selectedYear
GROUP BY transactionDate">
            <SelectParameters>
                <asp:ControlParameter ControlID="selectedYear" DefaultValue="2013" 
                    Name="selectedYear" PropertyName="Value" />
            </SelectParameters>
        </asp:SqlDataSource>
    </p>
    
    <table class="style1">
        <tr>
            <td>
                <h2>Quaterly Transaction </h2></td>
        </tr>
        <tr>
            <td>
                <asp:SqlDataSource ID="SqlDataSourceQ1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT        Quaters, SUM(transactionAmount) AS transactionAmount
FROM            (SELECT        CASE WHEN transactionDate &lt;= 3 THEN 'Quater 1' WHEN transactionDate &gt; 3 AND transactionDate &lt;= 6 THEN 'Quater 2' WHEN transactionDate &gt; 6 AND
                                                     transactionDate &lt;= 9 THEN ' Quater 3' ELSE 'Quater 4' END AS Quaters, transactionAmount
                          FROM            (SELECT        CAST(CONVERT(nvarchar(2), transactionDate, 101) AS int) AS transactionDate, SUM(ABS(transactionAmount)) AS transactionAmount
                                                    FROM            SUMMARY 
                                                    WHERE CONVERT(nvarchar(4), transactionDate, 111)=@selectedYear
                                                    GROUP BY transactionDate) AS Q) AS derivedtbl_1
GROUP BY Quaters">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="selectedYear" DefaultValue="2013" 
                            Name="selectedYear" PropertyName="Value" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <asp:Chart ID="ChartQ3" runat="server" DataSourceID="SqlDataSourceQ1">
                    <Series>
                        <asp:Series ChartType="Pie" Name="Series1" XValueMember="Quaters" 
                            YValueMembers="transactionAmount">
                        </asp:Series>
                    </Series>
                    <ChartAreas>
                        <asp:ChartArea Name="ChartArea1">
                        </asp:ChartArea>
                    </ChartAreas>
                </asp:Chart>
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
        </tr>
        </table>
    <p>
    </p>
</asp:Content>

